package com.study.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Calendar;

@Controller
public class LoginController {

    @GetMapping("toLoginPage")
    public String toLogin(Model model){
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }


    @RequestMapping("haha")
    public ModelAndView hello(HttpServletRequest request){

        System.out.println("进了haha");
        ModelAndView modelAndView = new ModelAndView();

        //1、获取请求参数
        String hahaname = request.getParameter("hahaname");
        System.out.println("hahaname =>"+hahaname);

        //2、携带数据跳转页面
        modelAndView.addObject("hahaname111", hahaname);

        //3、设置要跳转的路径页面
        modelAndView.setViewName("hello.html");

        return modelAndView;

    }

}
